<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        #app {
            margin: 0 auto;
            width: 80%;
            border: black 1px solid;
            height: 100vh;
        }
    </style>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    //4.工厂模式
    function getObject(id, name, age) {
        //先创建对象
        let obj = new Object()
        //对对象的属性进行赋值
        obj.id = id
        obj.name = name
        obj.age = age
        obj.info = function () {
            return this.id + "," + this.name + "," + this.age
        }
        //返回一个对象
        return obj
    }
    let p = getObject(1, "tom", 20)
    let p1 = getObject(1, "tom", 20)
    console.log(p.info())
    console.log(p === p1)
</script>

</html>